home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / wtek0693.zip / OOPALLEY.ZIP / RANDOM.CPP < prev    next >
C/C++ Source or Header  |  1993-04-27  |  615b  |  27 lines

  1. #include "random.h"
  2. #include "oopsconfig.h"
  3. #include <time.h>
  4.  
  5. #define THIS    Random
  6. #define BASE    Object
  7. DEFINE_CLASS(Random,Object);
  8.  
  9. //Random::Random()    { randx = time(&randx); randx ^= (long)this; }
  10. Random::Random()    { randx = time((time_t *)&randx); randx ^= (long)this; }
  11.  
  12. float Random::next() const
  13. {
  14.     /*register*/ float temp;
  15.     do temp = DRAW(randx)/(float)MAX_INT; while (temp==0);
  16.     return temp;
  17. }
  18.  
  19. Object* Random::copy() const      { return shallowCopy(); }
  20.  
  21. void Random::deepenShallowCopy()    {}
  22.  
  23. void Random::printOn(ostream& strm) const
  24. {
  25.     strm << randx;
  26. }
  27.